//
//  DFBaseViewController.swift
//  FlyBlog
//
//  Created by FEI on 16/4/8.
//  Copyright © 2016年 FEI. All rights reserved.
//

import UIKit

class DFBaseViewController: UITableViewController {

    var userLogin = DFUserAccountModel.shareInstance.userLogin

    override func loadView() {
        userLogin ? super.loadView() :
        setupVistorView()
    }

//    //MARK:按钮点击事件
//    @objc private func didClickRegister() {
//        print("didClickRegister")
//    }
//
//    @objc private func didClickLogin() {
//        print("didClickLogin")
//    }



    private func setupVistorView() {
        view = visitorView

        visitorView.delegate = self

        if self is DFHomeViewController {
        visitorView.iconViewRotateAnimation()
        }else if self is DFMessageViewController{
    visitorView.setupVisitorViewInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if self is DFDiscoverViewController{
    visitorView.setupVisitorViewInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")

        }else if self is DFProfileViewController{
    visitorView.setupVisitorViewInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }

        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style:UIBarButtonItemStyle.Plain , target: self, action: Selector("visitorViewDidClickRegisterButton"))

        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style:UIBarButtonItemStyle.Plain , target: self, action: Selector("visitorViewDidClickLoginButton"))
    }



    lazy var visitorView: DFVisitorView = DFVisitorView()
}

extension DFBaseViewController : DFVisitorViewDelegate {

    //MARK:代理方法
    func visitorViewDidClickRegisterButton() {
        print("register")
    }
    func visitorViewDidClickLoginButton() {
        let oauthVC = DFOauthViewController()
        let nav = UINavigationController(rootViewController: oauthVC)
        presentViewController(nav, animated: true, completion: nil)
    }

}
